<template>
  <div>
    <Mycart
      :data="goodList"
      @changeNum="changeNum"
      @deleted="deleted"
      @allCheck="allCheck"
      @changeCheck="changeCheck"
    ></Mycart>
  </div>
</template>

<script>
import Mycart from "@/components/fu-cart.vue";
export default {
  components: {
    Mycart,
  },
  data() {
    return {
      goodList: [
        {
          name: "诸葛亮",
          price: 1000,
          num: 1,
          checked: false,
        },
        {
          name: "蔡文姬",
          price: 1500,
          num: 1,
          checked: false,
        },
        {
          name: "妲己",
          price: 2000,
          num: 1,
          checked: false,
        },
        {
          name: "鲁班",
          price: 2200,
          num: 1,
          checked: false,
        },
      ],
    };
  },
  methods: {
    changeNum(i, value) {
      this.goodList[i].num = value;
    },
    deleted(i) {
      this.goodList.splice(i, 1);
    },
    allCheck(value) {
      this.goodList.forEach((item) => (item.checked = value));
    },
    changeCheck(i, v) {
      this.goodList[i].checked = v;
    },
  },
};
</script>
